from PyQt5.QtWidgets import *
from myutil import globalvar as gl, logs
from ui.main import Ui_MainWindow as main_window


class main_win(QMainWindow, main_window):
    def __init__(self, parent=None):
        super(main_win, self).__init__(parent)
        self.setupUi(self)

        # 设置底部状态栏显示信息
        self.statusbar.showMessage("设置底部状态栏显示信息")

        # 视图设置
        self.action_view_triggered_setting()

        # action 设置
        self.action_about.triggered.connect(self.action_about_event)

    def action_view_triggered_setting(self):
        self.dock_widget_1.hide()
        self.dock_widget_2.hide()
        self.dock_widget_3.hide()
        self.action_dock_widget_1.setIconVisibleInMenu(False)
        self.action_dock_widget_2.setIconVisibleInMenu(False)
        self.action_dock_widget_3.setIconVisibleInMenu(False)

        self.view_show_list = [0, 0, 0]
        self.action_dock_widget_1.triggered.connect(self.action_dock_widget_1_event)
        self.action_dock_widget_2.triggered.connect(self.action_dock_widget_2_event)
        self.action_dock_widget_3.triggered.connect(self.action_dock_widget_3_event)

    def action_dock_widget_1_event(self):
        logs.logs_print("设置停靠窗口1的开关")
        if self.view_show_list[0] == 1:
            self.view_show_list[0] = 0
            self.action_dock_widget_1.setIconVisibleInMenu(False)
            self.dock_widget_1.hide()
        else:
            self.view_show_list[0] = 1
            self.action_dock_widget_1.setIconVisibleInMenu(True)
            self.dock_widget_1.show()

    def action_dock_widget_2_event(self):
        logs.logs_print("设置停靠窗口2的开关")
        if self.view_show_list[1] == 1:
            self.view_show_list[1] = 0
            self.action_dock_widget_2.setIconVisibleInMenu(False)
            self.dock_widget_2.hide()
        else:
            self.view_show_list[1] = 1
            self.action_dock_widget_2.setIconVisibleInMenu(True)
            self.dock_widget_2.show()

    def action_dock_widget_3_event(self):
        logs.logs_print("设置停靠窗口3的开关")
        if self.view_show_list[2] == 1:
            self.view_show_list[2] = 0
            self.action_dock_widget_3.setIconVisibleInMenu(False)
            self.dock_widget_3.hide()
        else:
            self.view_show_list[2] = 1
            self.action_dock_widget_3.setIconVisibleInMenu(True)
            self.dock_widget_3.show()

    def action_about_event(self):
        logs.logs_print("关于软件")
        QMessageBox.about(self, "关于软件",
                          "  作者  ：参考答案开心否\n   QQ  ：983214439\n Gitee   ：wp19991\n GitHub ：wp19991\n  网站  ：wp19991.cn")
